#ifndef _DEBUG_H_
#define _DEBUG_H_


#define COLOR_RED "\x1B[31m"
#define COLOR_GREEN "\x1B[32m"
#define COLOR_YELLOW "\x1B[33m"
#define COLOR_NORMAL "\x1B[0m"

#define DEBUG	1

#define bufferDEBUG(buffer) { \
		int _bufferDEBUGi; \
		for(_bufferDEBUGi = 0;_bufferDEBUGi < sizeof(buffer); _bufferDEBUGi++) { \
			printf("%02x ", ((char*)buffer)[_bufferDEBUGi]); \
		} printf("\n"); }

#define notimplemented()  { pDEBUG("not implemented!\n"); exit(-1); }

#define pDEBUG(...)   if (DEBUG){ \
        printf("%s%s%s at %s:%d -- %s",\
                        COLOR_GREEN,\
                        __FUNCTION__,\
                        COLOR_NORMAL,\
                        __FILE__,\
                        __LINE__,\
                        COLOR_YELLOW); \
	printf(__VA_ARGS__); \
        printf("%s",COLOR_NORMAL); }



#define pnDEBUG(...)   if (DEBUG){ \
        printf("%s",COLOR_YELLOW); \
        printf(__VA_ARGS__); \
        printf("%s",COLOR_NORMAL); \
        fflush(stdout); }

// #define pERROR(...)  { fprintf(stderr,"%s: ", __FUNCTION__); fprintf(stderr,__VA_ARGS__); }

#endif
